package com.ceba.test.modules.signvisual.logicService;

import abc.ID;
import com.alibaba.fastjson.JSON;
import com.ceba.base.enums.GFileContentTypeEnum;
import com.ceba.base.helper.LoggerHelper;
import com.ceba.base.utils.IDSStringUtils;
import com.ceba.base.utils.PdfSignUtils;
import com.ceba.base.utils.ToPdfUtils;
import com.ceba.base.web.response.IResult;
import com.ceba.base.web.response.ResultJson;
import com.ceba.cebacer.KeyLoaderType;
import com.ceba.cebautils.DateUtil;
import com.ceba.cebautils.StringUtil;
import com.ceba.test.base.config.LogicPathUtil;
import com.ceba.test.base.configs.ServerSignConfig;
import com.ceba.test.base.constants.CustomStampConstants;
import com.ceba.test.base.entity.PdfImage;
import com.ceba.test.base.entity.SignPrintPDF;
import com.ceba.test.base.enums.FileFlagEnum;
import com.ceba.test.base.enums.ResultStatusEnum;
import com.ceba.test.base.enums.StampTypeEnum;
import com.ceba.test.base.language.ResourceUtils;
import com.ceba.test.modules.admin.entity.GStamp;
import com.ceba.test.modules.admin.entity.ISign;
import com.ceba.test.modules.admin.helper.QRCodeHelper;
import com.ceba.test.modules.admin.service.InterfaceSignService;
import com.ceba.test.modules.admin.service.StampService;
import com.ceba.test.modules.filemanage.dto.VFileObject;
import com.ceba.test.modules.filemanage.entity.GFile;
import com.ceba.test.modules.filemanage.entity.GFileRelaction;
import com.ceba.test.modules.filemanage.logicService.FileManageLogicService;
import com.ceba.test.modules.log.helper.RestLogHelper;
import com.ceba.test.modules.log.logicService.LogLogicService;
import com.ceba.test.modules.sign.logicService.SignLogicService;
import com.ceba.test.modules.signvisual.entity.HandWriteSignRequest;
import com.ceba.test.modules.signvisual.logicService.custom.CustomStampSignLogicService;
import com.ceba.test.modules.signvisual.logicService.custom.CustomStampSignVisualLogicService;
import com.ceba.test.modules.signvisual.service.SignPrintPdfComparator;
import com.ceba.test.modules.signvisual.service.ThirdCustomSignService;
import com.ceba.test.modules.statistic.entity.ReportSign;
import com.ceba.test.modules.storage.logicService.StorageFileCacheManage;
import com.httpclient.HttpClientUtil;
import com.httpclient.common.HttpConfig;
import configs.context.SpringBeans;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.math.NumberUtils;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sun.misc.BASE64Encoder;

import java.io.File;
import java.net.URLEncoder;
import java.util.*;

public class SignVisualLogicService {
	static Logger logger = LoggerFactory.getLogger(ThirdCustomSignService.class);
	
	private SignLogicService signLogicService = SpringBeans.getSignLogicService("signLogicService");
	private FileManageLogicService  fileManageLogicService = SpringBeans.getFileManageLogicService("fileManageLogicService");
	private CustomStampSignLogicService customStampSignLogicService = SpringBeans.getCustomStampSignLogicService("customStampSignLogicService");
	private CustomStampSignVisualLogicService customStampSignVisualLogicService = SpringBeans.getCustomStampSignVisualLogicService("customStampSignVisualLogicService");
	private LogLogicService logLogicService = SpringBeans.getLogLogicService("logLogicService");
	
	private ThirdCustomSignService thirdCustomSignService;
	private StampService stampService ;
	private InterfaceSignService interfaceSignService ;
	

	public SignLogicService getSignLogicService() {
		return signLogicService;
	}



	public void setSignLogicService(SignLogicService signLogicService) {
		this.signLogicService = signLogicService;
	}




	public ThirdCustomSignService getThirdCustomSignService() {
		return thirdCustomSignService;
	}



	public void setThirdCustomSignService(ThirdCustomSignService thirdCustomSignService) {
		this.thirdCustomSignService = thirdCustomSignService;
	}



	public StampService getStampService() {
		return stampService;
	}



	public void setStampService(StampService stampService) {
		this.stampService = stampService;
	}



	public InterfaceSignService getInterfaceSignService() {
		return interfaceSignService;
	}



	public void setInterfaceSignService(InterfaceSignService interfaceSignService) {
		this.interfaceSignService = interfaceSignService;
	}



	//CustomSignService 类

	

	/**
	 * 取得文件的正式路径
	 * @param fileId
	 * @param isTemplates
	 * @return
	 */
	public String getFilePath(String fileId,String isTemplates){
		return customStampSignLogicService.getFilePath(fileId, isTemplates);
	}
	
	
	/**
	 * 获取pdf图片
	 * @param pdfPath
	 * @return
	 */
	public Map<String, Object> getPdfImageList(String storageAddressId,String pdfPath){
		return customStampSignLogicService.getPdfImageList(storageAddressId,pdfPath);
	}
	
	
	
	/**
	 * 获取签章
	 * @return
	 */
	private List<GStamp> getG_StampList(Map<String, Object> paramMap){
		return customStampSignLogicService.getG_StampList(paramMap);
	}
	
	
	/**
	 * 加载PDF和签章
	 * @param g_stempIds 签章ID 字符串 用 逗号隔开
	 * @param fileId 文件ID
	 * @param isTemplates 是否是模板文件，还是报告文件
	 * @return
	 */
	public String loadPDFSignParameter(String g_stempIds,String fileId,String isTemplates){
		 return customStampSignLogicService.loadPDFandSign(g_stempIds, fileId, isTemplates );
	}



	/**
	 * 判断签名文件是否合格
	 * @param relaction_id
	 */
	public String isSignFile(String relaction_id) {
		StringBuffer buffer=new StringBuffer();
		GFileRelaction gfr= fileManageLogicService.isSignFile(relaction_id);
		String fileName= gfr.getFileName();
		String flag= gfr.getFlag();
		if(!IDSStringUtils.isEndsWith("doc,docx,pdf,png,jpg,gif,txt",fileName) || StringUtils.equals(flag, FileFlagEnum.SIGN.getFlag())){
			buffer.append(ResourceUtils.getMessage("MODULES_A_FILE_SIGNATURE_NOT_SUCCESSFUL_CHECK_FILE")+"</br>");
			buffer.append("<ul id='ftip'>");
			buffer.append("<li>"+ResourceUtils.getMessage("MODULES_DIGITAL_SIGNATURE_ONLY_SUPPORT_FORMATS_WORD_SOON")+"</li>");
			buffer.append("<li>"+ResourceUtils.getMessage("MODULES_DO_NOT_SUPPORT_DUPLICATION_DIGITAL_SIGNATURE")+"</li>");
			buffer.append("<li>"+ResourceUtils.getMessage("MOUDLEW_DOCUMENT_DIGITAL_SIGNATURE_NOT_SUPPORT")+"</li>");
			buffer.append("</ul>");
		}
		return buffer.toString();
	}
	
	
	//SignVisualService类

	/**
	 * 加载PDF和签章
	 * @param g_stempIds 签章ID 字符串 用 逗号隔开
	 * @param fileId 文件ID
	 * @param isTemplates 是否是模板文件，还是报告文件
	 * @return
	 */
	public String loadPDFandSign(String g_stempIds,String fileId,String isTemplates){
		return customStampSignVisualLogicService.loadPDFandSign(g_stempIds, fileId, isTemplates);
	}
	
	
	/**
	 * PDF打印签章
	 * @return
	 */
	public String pdfPrintSign(List<SignPrintPDF> signPrintPDFList,String signFilePath){
		return customStampSignVisualLogicService.pdfPrintSign(signPrintPDFList, signFilePath);
	}
	

    //ThirdCustomSignService 类
	
	/**
	 * 手写请求
	 * @return
	 */
	public IResult handWriteRequest(String signPageKey) {
		return thirdCustomSignService.handWriteRequest(signPageKey);
	}
	
	/**
	 * 上传base64
	 * @param request
	 * @return
	 */
	public IResult handWriteUpload(HandWriteSignRequest request) {
		String storageId =StorageFileCacheManage.getSystemUseAddressId();
		//虚拟路径存储图片
		String imgFilePath=LogicPathUtil.getPhysicalTempDirPath(storageId)+ID.getGuid()+".png";
		String  imgVerFilePath = LogicPathUtil.getVirtualPath(storageId,imgFilePath);
		return thirdCustomSignService.handWriteUpload(request,imgFilePath,LogicPathUtil.getBrowserPath(storageId,imgVerFilePath));
	}
	
	/**
	 * 请求章
	 * @param signPageKey
	 * @return
	 */
	
	public IResult stampRequest(String signPageKey) {
		return thirdCustomSignService.stampRequest(signPageKey);
	}
	
	
	/**
	 * 关闭手写页面
	 * @param request
	 * @return
	 */
	public IResult handWriteClose(HandWriteSignRequest request) {
		return thirdCustomSignService.handWriteClose(request);
	}
	

	/**
	 * 获取pdf路径
	 * @return uploadBashFilePath
	 */
	@SuppressWarnings({ "rawtypes", "unchecked" })
	private Map<String,String> getPdfPath(String fileId){
		Map<String,String> resultMap=new HashMap();
		String fileName=null,filePath=null;

		List<VFileObject> vfs = fileManageLogicService.getFileInfosById(fileId);
		if(vfs !=null && vfs.size() >0 ){
			VFileObject vf = vfs.get(0);
			if(!StringUtil.isEmptyString(vf.getFilePath())){
				filePath = vf.getFilePath();
				fileName = vf.getFileRelactionName();
				resultMap.put("fileName", fileName);
				resultMap.put("filePath", filePath);
				resultMap.put("fileId", fileId);
				resultMap.put("storageAddressId",vf.getStorageAddressId());
			}
		}
 		return resultMap;
	}

	/**
	 * 签章打印PDF操作
	 * @param pdfPath
	 * @return
	 */
	private ResultJson signPrintPDFsealCMA(List<SignPrintPDF> signPrintPDFList,
			String pdfPath, ISign iSign,String loginUserId,ReportSign  parm ,String storageId,String fileName){
	     	ResultJson resultJson=new ResultJson();
		try {
			String outPath=LogicPathUtil.getPhysicalSignFolderByUserId(storageId,loginUserId)+DateUtil.getDayTime(null,0)+File.separator+fileName+".pdf";
			new File(LogicPathUtil.getPhysicalSignFolderByUserId(storageId,loginUserId)+DateUtil.getDayTime(null,0)+File.separator).mkdirs();
			Map<String, List<GStamp>> g_StampMap=signPrintPDFToIdG_Stamp(signPrintPDFList,iSign);
			JSONObject re = signLogicService.signVisualStampFacade(pdfPath, outPath, true, g_StampMap,iSign,parm,storageId);
			if(re.getString("code").equals("200")){
				outPath=re.getString("outPath")	;
			}else{
				resultJson.setStatus(ResultStatusEnum.SB.getCode());
				resultJson.setMessage(re.getString("message"));
				return resultJson;
			}
			File outFile=new File(outPath);
			if(outFile.isFile()){
				resultJson.setStatus(ResultStatusEnum.CG.getCode());
				resultJson.setData(LogicPathUtil.getBrowserPath(storageId,LogicPathUtil.getVirtualPath(storageId,outPath)));
			}else{
				resultJson.setStatus(ResultStatusEnum.SB.getCode());
				resultJson.setMessage(re.getString("message"));
			}
		} catch (Exception e) {
			resultJson.setStatus(ResultStatusEnum.SB.getCode());
			resultJson.setMessage(e.getMessage());
			LoggerHelper.error(logger, e, "");
		}
		return resultJson;
	}


	
	
	/**
	 * 加载PDF和签章
	 * @param iSignId
	 * @param fileId 文件ID
	 * @return
	 * @throws Exception 
	 */
	@SuppressWarnings("unchecked")
	public String loadPDFandSignByISignId(String iSignId,String fileId,Map<String,Object> dic){
		Map<String, Object> map=new HashMap<String,Object>();
		boolean isSign=false;//判断文件是否签名
		boolean isServerSign=true;
		try{
			ISign iSign = interfaceSignService.getInterfaceSignById(iSignId);
			String g_stempIds = "";
			if(iSign != null){
				g_stempIds = iSign.getStampID();
				
				Map<String, Object> paramMap=new HashMap<>();
				paramMap.put("g_stempIds", g_stempIds);

				//将dateName和dateContent放入map中
				String dateName=(String)dic.get("dateName");
				String dateContent=(String)dic.get("dateContent");
				paramMap.put("dateName",dateName);
				paramMap.put("dateContent",dateContent);

				List<GStamp> g_StampList=getG_StampList(paramMap);
				
				//判断是服务器签名   还是key签名 
				if(iSign.getKeyType()==KeyLoaderType.TYPE_CEBA_KEY){
					isServerSign=false;
				}
				map.put(CustomStampConstants.G_STAMPLIST, g_StampList);
			}
			Map<String,String> fileMap= getPdfPath(fileId);
			String pdfPath=fileMap.get("filePath");
	 		Map<String,Object> resultMap=getPdfImageList(StorageFileCacheManage.getSystemUseAddressId(),pdfPath);
	 		int totalPageCount= ToPdfUtils.getPagesOfPdf(pdfPath);
	 		boolean isRsaSign = PdfSignUtils.checkFileHasRSASigned(pdfPath);
	 		boolean isSm2Sign = PdfSignUtils.checkFileHasSM2Signed(pdfPath);
	 		//设置签章图片
			map.put(CustomStampConstants.PDFIMAGELIST, (List<PdfImage>)resultMap.get("pdfImageList"));
			
			//TODO 根据实际情况而定
			map.put(CustomStampConstants.PDFNAME,fileMap.get("fileName"));
			
			//获取文件名称
			String fileName=fileMap.get("fileName");
			String result=null;
			if(StringUtils.isNotBlank(fileName) &&  fileName.length()>15){
				result=fileName.substring(0, 15)+"...";
			}
			map.put("pdfNameStr", result);
			map.put("fileId",fileMap.get("fileId"));
			
			//获取总页数
			map.put("totalPageCount",totalPageCount);
			map.put("signFilePath", ObjectUtils.toString(resultMap.get("tempFilePath")));
			// 绝对路径
			map.put("filePath", ObjectUtils.toString(resultMap.get("tempFilePath")));
			map.put("virtualPath", LogicPathUtil.getBrowserPath(StorageFileCacheManage.getSystemUseAddressId(),LogicPathUtil.getVirtualPath(StorageFileCacheManage.getSystemUseAddressId(),ObjectUtils.toString(resultMap.get("tempFilePath")))));
			// newFileId
			map.put("newFileId",fileMap.get("fileId"));

			map.put("storageAddressId", fileMap.get("storageAddressId"));
			//手写签名key
			map.put("handSignKey", ID.getGuid());
			//用做页面判断 是服务器签名  还是key签名
			map.put("isServerSign", isServerSign);

			//是否可以复制  是否可以打印
			map.put("allowCopy",iSign.getAllowPdfContentCopy());
			map.put("allowPrint",iSign.getAllowPdfPrint());

			//判断文件是否签名
			if(isRsaSign||isSm2Sign){
				isSign=true;
			}
			map.put(CustomStampConstants.ISSIGN, isSign);
			
			
		}catch(Exception e){
			LoggerHelper.error(logger, e, "");
		}
		return JSON.toJSONString(map);
	}
	
	/**
	 * PDF打印签章
	 * @return
	 */
	public String pdfPrintSignCMA(List<SignPrintPDF> signPrintPDFList,String signFilePath,String iSignId,String loginUserId,ReportSign  parm, String storageId,String fileName){
		ResultJson resultJson= new ResultJson();
		resultJson.setStatus(ResultStatusEnum.SB.getCode());
		try{
			ISign iSign = interfaceSignService.getInterfaceSignById(iSignId);
			//拖拽一定是按位置签名
			iSign.setSignType(1);
			resultJson=signPrintPDFsealCMA(signPrintPDFList,signFilePath,iSign,loginUserId,parm,storageId,fileName);
		}catch(Exception e){
			LoggerHelper.error(logger, e, "");
		}
		return JSON.toJSONString(resultJson);
	}

	
	/**
	 * signPrintPdf转换为g_stamp
	 * @return
	 */
	public GStamp signPrintPDFToG_Stamp(GStamp g_stamp,SignPrintPDF signPrintPDF){
		g_stamp.setId(signPrintPDF.getId());
		g_stamp.setUserId(signPrintPDF.getUserid());
		g_stamp.setStamp_x(signPrintPDF.getPdf_x());
		g_stamp.setStamp_y(signPrintPDF.getPdf_y());
		g_stamp.setStampPage(signPrintPDF.getPage());	
		float imgWidth = signPrintPDF.getImageWidth()*NumberUtils.toFloat(signPrintPDF.getZoomRate(),1);
		float imgHeight = signPrintPDF.getImageHeight()*NumberUtils.toFloat(signPrintPDF.getZoomRate(),1);
		g_stamp.setImgHeight(ObjectUtils.toString(imgHeight));
		g_stamp.setImgWidth(ObjectUtils.toString(imgWidth));
		g_stamp.setFilePath(signPrintPDF.getImagePath());
		g_stamp.setPositionRate(NumberUtils.toFloat(signPrintPDF.getPositionRate()));
//		g_stamp.setStorageAddressId(LogicPathUtil.browserPathToStorageAddressId(g_stamp.getFilePath()));
		g_stamp.setStorageAddressId(StorageFileCacheManage.getSystemUseAddressId());
		g_stamp.setFilePath(LogicPathUtil.browserPathToVirtualPath(g_stamp.getFilePath()));
//		g_stamp.setFilePath(LogicPathUtil.getVirtualPath(StorageFileCacheManage.getSystemUseAddressId(),g_stamp.getFilePath()));

		return g_stamp;
	}
	

	
	
	/**
	 * 与业务关联获取签章数据
	 * @param signPrintPdfList
	 * @throws Exception
	 */
	public Map<String, List<GStamp>> signPrintPDFToIdG_Stamp(List<SignPrintPDF> signPrintPdfList,ISign iSign) throws Exception{
		if(CollectionUtils.isEmpty(signPrintPdfList)){
			return null;
		}
		Map<String, List<GStamp>> g_StampMap=new HashMap<>();
		int key =0;
		for(SignPrintPDF signPrintPDF : signPrintPdfList){
			//判断是不是骑缝章
			if(signPrintPDF.getStampType().equals(StampTypeEnum.QIFENG_COR_STAMP_FLAG.getType())){
				GStamp g_stamp = stampService.getStampById(iSign.getStampID());
				signPrintPDF.setImageHeight(NumberUtils.toFloat(g_stamp.getImgHeight()));
				signPrintPDF.setImageWidth(NumberUtils.toFloat(g_stamp.getImgWidth()));
				signPrintPDF.setImagePath(signPrintPDF.getImagePath());
				g_stamp=signPrintPDFToG_Stamp(g_stamp,signPrintPDF);
				g_stamp.setCorFlag(StampTypeEnum.QIFENG_COR_STAMP_FLAG.getType());
				addMapList(g_StampMap,key+"",g_stamp);
			//判断是不是水印	
			}else if(signPrintPDF.getStampType().equals(StampTypeEnum.WATERMARK_COR_STAMP_FLAG.getType())){
				GStamp g_stamp = stampService.getStampById(signPrintPDF.getId());
				signPrintPDF.setImageHeight(NumberUtils.toFloat(g_stamp.getImgHeight()));
				signPrintPDF.setImageWidth(NumberUtils.toFloat(g_stamp.getImgWidth()));
				signPrintPDF.setImagePath(signPrintPDF.getImagePath());
				g_stamp=signPrintPDFToG_Stamp(g_stamp,signPrintPDF);
				g_stamp.setCorFlag(StampTypeEnum.WATERMARK_COR_STAMP_FLAG.getType());
				addMapList(g_StampMap,key+"",g_stamp);
				
		       //签名章 (手写体  即 用户章)
			}else if(signPrintPDF.getStampType().equals(StampTypeEnum.USER_COR_STAMP_FLAG.getType())){
				GStamp g_stamp = new GStamp();
//				signPrintPDF.setImageHeight(NumberUtils.toFloat("75"));//默认宽高为75
//				signPrintPDF.setImageWidth(NumberUtils.toFloat("75"));
				signPrintPDF.setImagePath(signPrintPDF.getImagePath());
				g_stamp=signPrintPDFToG_Stamp(g_stamp,signPrintPDF);
				g_stamp.setCorFlag(StampTypeEnum.USER_COR_STAMP_FLAG.getType());
				addMapList(g_StampMap,key+"",g_stamp);
				
			}else if(signPrintPDF.getStampType().equals(StampTypeEnum.CREDIENTAL_COR_DATE_STAMP_FLAG.getType())){
				GStamp g_stamp = stampService.getStampById(signPrintPDF.getId());
				signPrintPDF.setImageHeight(NumberUtils.toFloat(g_stamp.getImgHeight()));
				signPrintPDF.setImageWidth(NumberUtils.toFloat(g_stamp.getImgWidth()));
				signPrintPDF.setImagePath(signPrintPDF.getImagePath());
				g_stamp=signPrintPDFToG_Stamp(g_stamp,signPrintPDF);
				g_stamp.setCorFlag(StampTypeEnum.CREDIENTAL_COR_DATE_STAMP_FLAG.getType());
				addMapList(g_StampMap,key+"",g_stamp);
		
			}else if(signPrintPDF.getStampType().equals(StampTypeEnum.USER_COR_EXAMINE_STAMP_FLAG.getType())){
				GStamp g_stamp = new GStamp();
				signPrintPDF.setImagePath(signPrintPDF.getImagePath());
				g_stamp=signPrintPDFToG_Stamp(g_stamp,signPrintPDF);
				g_stamp.setCorFlag(StampTypeEnum.USER_COR_EXAMINE_STAMP_FLAG.getType());
				addMapList(g_StampMap,key+"",g_stamp);
			}else{
				
				GStamp g_stamp = stampService.getStampById(signPrintPDF.getId());
//				signPrintPDF.setImageHeight(NumberUtils.toFloat(g_stamp.getImgHeight()));
//				signPrintPDF.setImageWidth(NumberUtils.toFloat(g_stamp.getImgWidth()));
				signPrintPDF.setImagePath(signPrintPDF.getImagePath());
				g_stamp=signPrintPDFToG_Stamp(g_stamp,signPrintPDF);
				addMapList(g_StampMap,key+"",g_stamp);
			}
			
			key++;
		}
		return g_StampMap;
	}
	/**
	 * 添加数据
	 * @param g_StampMap
	 * @param key
	 * @param g_Stamp
	 */
	private void addMapList(Map<String,List<GStamp>> g_StampMap,String key,GStamp g_Stamp){
		if(g_Stamp == null) return ;
		if(CollectionUtils.isEmpty(g_StampMap.get(key))){
			g_StampMap.put(key, new ArrayList<GStamp>());
		}
		g_StampMap.get(key).add(g_Stamp);
	}

	/*
	 * 上传第三方签名的文档的相对路径，由对方下载
	 */
	public boolean uploadToThirdSystem(JSONObject json) {
		try{
			BASE64Encoder base64Encoder = new BASE64Encoder();
			String param = URLEncoder.encode(base64Encoder.encode(json.toString().getBytes("utf-8")),"utf-8");
			StringBuffer urlStr = new StringBuffer(ServerSignConfig.thirdUploadFileSystemUrl);
			if(!StringUtil.isEmptyString(urlStr.toString())){
				urlStr.append("?json="+param);
				HttpConfig  config = HttpConfig.custom().url(urlStr.toString());
		    	int statusCode = HttpClientUtil.status(config);
		    	
		    	String relativePath = json.getJSONObject("sign").getString("filePath");
		    	if(statusCode != 200){
		    		String result = ResourceUtils.getMessage("MODULES_PLEASE_FILE")+relativePath+ResourceUtils.getMessage("MODULES_THROUGH_INTERFACE")
		    				+ServerSignConfig.thirdUploadFileSystemUrl+ResourceUtils.getMessage("MODULES_UPLOAD_FAILURE_CAUSE");
		    		RestLogHelper.fnEndDebug(Thread.currentThread().getName(), "uploadToThirdSystem", result);
		    	}else{
		    		String result = ResourceUtils.getMessage("MODULES_PLEASE_FILE")+relativePath+ResourceUtils.getMessage("MODULES_THROUGH_INTERFACE")
		    				+ServerSignConfig.thirdUploadFileSystemUrl+ResourceUtils.getMessage("HANDWRITTEN_UPLOAD_SUCCESS");
		    		RestLogHelper.fnEndDebug(Thread.currentThread().getName(), "uploadToThirdSystem", result);
		    		return true;
		    	}
			}
		}catch(Exception e){
			LoggerHelper.error(e,"");
		}
		return false;
	}
	
}
